<template>
  <div>
    <Nav :title="$route.name"></Nav>
    <div class="container">
      <div class="m20 item_head item_btn item_one" @click="$router.push('/permes')">
        <img :src="$store.state.user.url" alt="" />
        <span>{{$store.state.user.nick}}</span>
        <i></i>
      </div>
      <div class="item_head item_btn">
        <span>会员码</span>
        <div class="code_icon"></div>
        <i></i>
      </div>
      <div class="item_head item_btn">
        <span>我的信息</span>
        <p>添加宝宝/尺码等信息</p>
        <i></i>
      </div>
      <div class="item_head m20 item_btn" @click="$router.push('/addresssMange')">
        <span>地址管理</span>
        <p>新增/修改地址</p>
        <i></i>
      </div>
      <div class="item_head item_btn">
        <span>账户安全</span>
        <p>修改密码/修改手机</p>
        <i></i>
      </div>
      <div class="item_head item_btn">
        <span>增票资质</span>
        <p>个人增票认证</p>
        <i></i>
      </div>
      <div class="item_head item_btn m20">
        <span>关联账号</span>
        <p>微信等</p>
        <i></i>
      </div>
      <button class="exit_login" @click="exitLogin">退出登录</button>
    </div>
  </div>
</template>

<script>
import Nav from '../../components/Nav.vue'
import { Dialog } from 'vant'
import { fetchExitLogin } from '_api'
import { getToken } from '_utils/token.js'
export default {
  components: { Nav },
  data () {
    return {

    }
  },
  methods: {
    exitLogin () {
      Dialog.confirm({
        message: '是否退出当前登录'
      })
        .then(() => {
          fetchExitLogin({
            token: getToken()
          }).then(res => {
            if (res.data.code === 0) {
              localStorage.removeItem('token')
              this.$store.commit('cart/set_info', {
                item: [],
                number: 0
              })
              this.$router.replace('/home')
            }
          })
        })
        .catch(() => {
          // on cancel
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.m20 {
  margin-bottom: 0.266667rem;
}
.container {
  padding-top: 1.2rem;
  .item_head.item_one {
    height: 1.866667rem;
    span{
      font-size: .373333rem;
    }
  }
  .item_btn {
    padding: 0 0.333333rem;
    display: flex;
    height: 1.2rem;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    border-bottom: 1px solid #f2f2f2;
    img {
      width: 1.2rem;
      height: 1.2rem;
      border-radius: 0.6rem;
      margin-right: 0.266667rem;
    }
    span {
      flex: 1;
      font-size: .373333rem;
      color: #333;
    }
    .code_icon{
      width: .426667rem;
      height: .426667rem;
      background:url("../../assets/vip_code.png") no-repeat;
      background-size: contain;
    }
    p{
      font-size: .4rem;
      color: #999;
    }
    i {
      width: 0.16rem;
      height: 0.293333rem;
      background: url("../../assets/ro.png") no-repeat;
      background-size: contain;
      margin-left: .266667rem;
    }
  }
}
.exit_login{
  display: block;
  width: 9.066667rem;
  height: 1.066667rem;
  border:none;
  margin: .8rem auto .533333rem;
  background-color: #f60;
 line-height: 1.066667rem;
  text-align: center;
  font-size: .4rem;
  color: #fff;
  border-radius: .266667rem;

}
</style>
